/**
 * 将表单数据序列化
 * @param data
 * @returns {string}
 */
const serializeData = data => {
  let result = [];
  for (let i in data) {
    if (Object.prototype.hasOwnProperty.call(data, i)) {
      result.push(
        i + '=' + encodeURIComponent(data[i] === undefined ? '' : data[i])
      );
    }
  }
  return result.join('&');
};

export default {
  serializeData
};
